package com.example.hello;

import com.example.hello.client.Alert.BootstrapAlertState;
import com.vaadin.ui.AbstractComponent;

public class BootstrapAlert extends AbstractComponent {

    public enum AlertType {
        DEFAULT, ERROR, INFO, SUCCESS, WARNING
    }

    public BootstrapAlert() {
        this("");
    }

    public BootstrapAlert(String text) {
        this(text, AlertType.DEFAULT);
    }

    public BootstrapAlert(String text, AlertType type) {
        setHeading(text);
        setType(type);
    }

    @Override
    protected BootstrapAlertState getState() {
        return (BootstrapAlertState) super.getState();
    }

    public boolean isAnimation() {
        return getState().isAnimation();
    }

    public void setAnimation(boolean animated) {
        getState().setAnimation(animated);
    }

    public boolean isClose() {
        return getState().isClose();
    }

    public void setClose(boolean hasClose) {
        getState().setClose(hasClose);
    }

    public String getHeading() {
        return getState().getHeading();
    }

    public void setHeading(String heading) {
        getState().setHeading(heading);
    }

    public String getText() {
        return getState().getText();
    }

    public void setText(String text) {
        getState().setText(text);
    }

    public AlertType getType() {
        return AlertType.valueOf(getState().getType());
    }

    public void setType(AlertType type) {
        getState().setType(type.toString());
    }

}